<template>
  <div class="myBackground">
    <commonHeader :title="title" @goBack="goBack"></commonHeader>
    <div class="content">
      <!--      上传背景-->
      <div @click="upLoadBg()" class="contentItems borderBottom flex-space-between">
        <h3>上传背景</h3>
        <img class="rightIcon" src="http://job.dayinyun.com/rightIcon.png" alt="">
      </div>
      <!--      编辑个人资料-->
      <div @click="upLoadBg()" class="contentItems flex-space-between">
        <h3>编辑资料</h3>
        <img class="rightIcon" src="http://job.dayinyun.com/rightIcon.png" alt="">
      </div>
    </div>
    <!--    上传背景-->
    <cropperImg ref="cropperImg" :aspectRatio="aspectRatio" @saveBackground="saveBackground"></cropperImg>
  </div>
</template>

<script>
  import commonHeader from "../../components/common/commonHeader";
  import cropperImg from "../../components/cropperImg.vue"
  export default {
    name:"myBackground",
    components:{
      commonHeader,
      cropperImg
    },
    data() {
      return {
        title: "上传背景",
        aspectRatio:750 / 233,//裁剪图片比例
      }
    },
    methods:{
      // 返回
      goBack(){
        if (window.history.length>1){
          window.history.go(-1)
        }else {
          if (this.$systemInfo() === "android") {
            window.android.closeCurrentPage();
          } else if (this.$systemInfo() === "ios") {
            window.webkit.messageHandlers.closeCurrentPage.postMessage(null);
          }
        }
      },
      // 上传图片
      upLoadBg(){
        this.$refs.cropperImg.clickUploadBeforeImg();
      },
      // 保存用户背景图片
      saveBackground(){
        // 更新用户信息
        if (this.$systemInfo() === "android") {
          window.android.updateUserInfo();
        } else if (this.$systemInfo() === "ios") {
          window.webkit.messageHandlers.updateUserInfo.postMessage(null);
        }
      },
    }
  }
</script>

<style lang="less" scoped>
  @import (reference) url(../../assets/less/common);
  .myBackground{
    width:100%;
    padding-top:1.38rem ;
    box-sizing: border-box;
    .content{
      width:100%;
      padding:0 0.3rem;
      box-sizing: border-box;
      .contentItems{
        width:100%;
        height:1.1rem;
        h3{
          font-size:@fontSize34;
          font-family:@fontFamily400;
          font-weight:@fontWeight600;
          color:#FFFFFF;
        }
        img{
          width:0.28rem;
          height: auto;
        }
      }
      .borderBottom{
        border-bottom:0.02rem solid rgba(102,102,102,0.4);
      }
    }
  }

</style>
